// ===============================================================================
// scan: sequential scan of a large descriptor collection
// Created in September 2007 as a project for an Advanced Database Systems course
// (c) Reykjavik University, Björn Þór Jónsson, Kristleifur Daðason, Herwig Lejsek
// Contact author: Björn Þór Jónsson, Reykjavík University, bjorn@ru.is
// ===============================================================================

#ifndef DESCMAPPER
#define DESCMAPPER

#include <string>
#include <iostream>
#include <sys/stat.h>
#include <stdio.h>
#include <sys/types.h>
//#include <sys/mman.h>
#include <string.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>

#include "FlexDescriptor.h"

using namespace std;

class DescMapper
{
private:
	// File information
	FILE* file;
	unsigned char *mapPtr;
	unsigned int fileSize;

	// Metadata
	unsigned int numDescs;
	unsigned int numDims;
	unsigned int descSize;

	// Scan helper
	int currDesc;

public:
	DescMapper(string _filename, unsigned int _numDims); //
	~DescMapper();

	int getNumDescs() { return numDescs; };
	void open();
	FlexDescriptor* next();
	void close();
};

#endif
